package day007.api_date;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class SimpleDateFromatDemo {
    public static void main(String[] args) {
        Date date=new Date();

        SimpleDateFormat s1=new SimpleDateFormat("yyyy--MM--dd HH:mm:ss");
        String str1=s1.format(date);
        System.out.println(str1);
        System.out.println("----------");

        String str2="2024-11-04 16:45:30";
        SimpleDateFormat s2=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            Date date2=s2.parse(str2);
            System.out.println(date2);
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
    }
}
